package com.bhs.sansong.ui.findLogistics;

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansong.R;
import com.bhs.sansong.base.BaseActivity;
import com.bhs.sansong.utils.LogUtils;
import com.bhs.sansong.utils.MyUtils;
import com.bhs.sansong.view.ScaleImageView;
import com.bhs.sansong.view.Watermark;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.luck.picture.lib.utils.PictureFileUtils;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 查看附件
 */
public class CheckAttachmentActivity extends BaseActivity {


    private ImageView mIvAttachment;
    private FrameLayout mFlParent;
    @Override
    public int initLayout() {
        return R.layout.activity_check_attachment;
    }

    @Override
    public void initView() {
        LogUtils.d(getIntent().getStringExtra("attachment"));
        TextView mTvTitle = findViewById(R.id.tv_title);
        mTvTitle.setText(getIntent().getStringExtra("title"));
        mIvAttachment = findViewById(R.id.iv_attachment);
        mFlParent = findViewById(R.id.fl_parent);
        Watermark.getInstance().show(this,mFlParent);
    }

    @Override
    public void initData() {
        Glide.with(mActivity).asBitmap().load(getIntent().getStringExtra("attachment")).into(new CustomTarget<Bitmap>() {
            @Override
            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                mIvAttachment.setImageBitmap(resource);

            }

            @Override
            public void onLoadCleared(@Nullable Drawable placeholder) {

            }
        });
    }
}